package ru.pachkun.home.block;

import org.openqa.selenium.support.FindBy;

import ru.yandex.qatools.htmlelements.annotations.Name;
import ru.yandex.qatools.htmlelements.element.HtmlElement;
import ru.yandex.qatools.htmlelements.element.Select;
import ru.yandex.qatools.htmlelements.element.TextInput;

@Name("Блок первичного ключа")
public class BasicInformationRPOBlock extends HtmlElement {

	@FindBy(name = "operTypeID")
	private Select operTypeID;

	@FindBy(name = "operAttrID")
	private Select operAttrID;

	@FindBy(name = "mailCtgID")
	private Select mailCtgID;

	@FindBy(name = "dateOper")
	private TextInput dateOper;

	@FindBy(name = "indexOper")
	private TextInput indexOper;

	@FindBy(name = "barCode")
	private TextInput barCode;

	public BasicInformationRPOBlock setOperTypeID(String text) {
		if (text == null) {
			return this;
		}
		operTypeID.selectByVisibleText(text);
		return this;
	}

	public BasicInformationRPOBlock setOperAttrID(String text) {
		if (text == null) {
			return this;
		}
		operAttrID.selectByVisibleText(text);
		return this;
	}

	public BasicInformationRPOBlock setMailCtgID(String text) {
		if (text == null) {
			return this;
		}
		mailCtgID.selectByVisibleText(text);
		return this;
	}

	public BasicInformationRPOBlock setDateOper(String text) {
		if (text == null) {
			return this;
		}
		dateOper.sendKeys(text);
		return this;
	}

	public BasicInformationRPOBlock setIndexOper(String text) {
		if (text == null) {
			return this;
		}
		indexOper.sendKeys(text);
		return this;
	}

	public BasicInformationRPOBlock setBarCode(String text) {
		if (text == null) {
			return this;
		}
		barCode.sendKeys(text);
		return this;
	}

	public String getOperTypeID() {
		return operTypeID.getFirstSelectedOption().getText();
	}

	public String getOperAttrID() {
		return operAttrID.getFirstSelectedOption().getText();
	}

	public String getMailCtgID() {

		return mailCtgID.getFirstSelectedOption().getText();
	}

	public String getDateOper() {
		return dateOper.getText();
	}

	public String getIndexOper() {
		return indexOper.getText();
	}

	public String getBarCode() {
		return barCode.getText();
	}
	
	public void ensureOperAttrEnable() {
		
	}

}
